package com.wuchao.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 吴超66
 * @version 1.0
 * @date 2022/4/20 11:48
 */
@WebServlet("/E")
public class E1 extends HttpServlet {
    protected void doPost(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        PrintWriter out=response.getWriter();
        String name=(String) request.getParameter("name");
        if(name!=null&&name.equals("cc")){
            System.out.println("登录成功");
            session.setAttribute("name",name);
            request.getRequestDispatcher("t7.jsp").forward(request,response);
        }else{
            response.sendRedirect("t6.jsp?bb=f");
        }
        out.flush();
        out.close();
    }
    @Override
    public void init() throws ServletException {
        System.out.println("初始化时，执行init()方法！");
    }
}
